<%@ import ="com.noppanit.library.model.*" %>
<%@ import ="com.noppanit.library.interfaces.*" %>
<%@ import ="com.noppanit.library.implement.*" %>
<%@ import ="org.apache.lucene.*" %>
<%@ import ="org.apache.lucene.store.*" %>

<html>
    <head>
        <title>Welcome to Grails</title>
		<meta name="layout" content="main" />
    </head>
    <body>
        <h1 style="margin-left:20px;">Welcome to Grails</h1>
        <p style="margin-left:20px;width:80%">Congratulations, you have successfully started your first Grails application! At the moment
        this is the default page, feel free to modify it to either redirect to a controller or display whatever
        content you may choose. Below is a list of controllers that are currently deployed in this application,
        click on each to execute its default action:</p>
        <div class="dialog" style="margin-left:20px;width:60%;"> <br>
            <ul>

	      <%
		 Directory directory = FSDirectory.getDirectory('C:\\IndexDir' );	
		 LibrarianInterface library = new Librarian();
		 Book[] books = library.search(directory,'portal','filename')
	      %>
		
		<g:form controller="library" action="search" method="get">
			Search Query: <g:textField name="query" /> <input type="submit" value="search!" />
		</g:form>

		<br>

		<g:each in="${books?}">
			${it?.bookname} <br>
		</g:each>
            </ul>
        </div>
    </body>
</html>